package com.uex.dev.manage.admin.intercepter;

import com.uex.dev.manage.common.aop.BasicMvcConfig;
import com.uex.dev.manage.common.trace.TraceInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

/**
 * @author wangc
 * @create 2023/11/4
 * @description 登录token校验Interceptor
 */
@Configuration
public class AuthInterceptor extends BasicMvcConfig {

    @Resource
    private TokenInterceptor tokenInterceptor;
    @Resource
    private OpenidInterceptor openidInterceptor;
    @Resource
    private TraceInterceptor traceInterceptor;

    private final String[] excludePathPatterns = new String[]{
            "/user/login", "/wxapp/bind"
    };

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(traceInterceptor)
                .addPathPatterns("/**");
        registry.addInterceptor(openidInterceptor)
                .addPathPatterns("/**");
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludePathPatterns);

    }
}
